package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ArtistDownloadLog;
import com.ruoyi.system.service.IArtistDownloadLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 下载管理Controller
 * 
 * @author Yaphets
 * @date 2024-07-06
 */

@Api(tags = "下载管理")
@RestController
@RequestMapping("/system/artistDownloadLog")
public class ArtistDownloadLogController extends BaseController
{
    @Autowired
    private IArtistDownloadLogService artistDownloadLogService;

    /**
     * 查询下载管理列表
     */

    @ApiOperation(value = "查询下载管理列表")
    @ApiResponse(code = 200, message = "查询成功", response = ArtistDownloadLog.class)
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArtistDownloadLog artistDownloadLog)
    {
        startPage();
        List<ArtistDownloadLog> list = artistDownloadLogService.selectArtistDownloadLogList(artistDownloadLog);
        return getDataTable(list);
    }

    /**
     * 导出下载管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:export')")
    @Log(title = "下载管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArtistDownloadLog artistDownloadLog)
    {
        List<ArtistDownloadLog> list = artistDownloadLogService.selectArtistDownloadLogList(artistDownloadLog);
        ExcelUtil<ArtistDownloadLog> util = new ExcelUtil<ArtistDownloadLog>(ArtistDownloadLog.class);
        util.exportExcel(response, list, "下载管理数据");
    }

    /**
     * 获取下载管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(artistDownloadLogService.selectArtistDownloadLogById(id));
    }

    /**
     * 新增下载管理
     */
    @ApiOperation(value = "新增下载日志")
    @ApiResponse(code = 200, message = "新增成功")
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:add')")
    @Log(title = "下载管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArtistDownloadLog artistDownloadLog)
    {
        return toAjax(artistDownloadLogService.insertArtistDownloadLog(artistDownloadLog));
    }

    /**
     * 修改下载管理
     */
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:edit')")
    @Log(title = "下载管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArtistDownloadLog artistDownloadLog)
    {
        return toAjax(artistDownloadLogService.updateArtistDownloadLog(artistDownloadLog));
    }

    /**
     * 删除下载管理
     */
//    @PreAuthorize("@ss.hasPermi('system:artistDownloadLog:remove')")
    @Log(title = "下载管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(artistDownloadLogService.deleteArtistDownloadLogByIds(ids));
    }
}
